package com.example.demo.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;

public class SpringBootApplicationListener implements ApplicationListener<SpringApplicationEvent> {

    public static SpringApplication sa;
    public static String[] args;
    public static ConfigurableApplicationContext context;
    @Override
    public void onApplicationEvent(SpringApplicationEvent springApplicationEvent) {
        if (springApplicationEvent instanceof ApplicationPreparedEvent) {
            SpringBootApplicationListener.context = ((ApplicationPreparedEvent) springApplicationEvent).getApplicationContext();
            SpringBootApplicationListener.args = springApplicationEvent.getArgs();
            SpringBootApplicationListener.sa = springApplicationEvent.getSpringApplication();
        }
    }
}
